package com.blood.core.config.id;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author daoren
 * @date 2020/12/3 17:16
 * @Copyright
 * @description
 */
@Configuration
@Data
@Slf4j
public class SnowFlakeConfiguration {

    private int dataCenterId = 1;
    private int machineId = 1;

    @Bean
    public Snowflake snowFlake() {
        log.info("创建雪花算法计算器：{} @ {}", dataCenterId, machineId);
        return IdUtil.getSnowflake(dataCenterId, machineId);
    }
}
